package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理API", tags = "敏感词管理API")
public class AdSensitiveController {

    @Autowired
    AdSensitiveService adSensitiveService;

    @PostMapping("/list")
    @ApiOperation(value = "敏感词查询")
    public ResponseResult querySensitive(@RequestBody SensitiveDTO dto) {
        return adSensitiveService.querySensitiveList(dto);
    }

    @PostMapping("/save")
    @ApiOperation(value = "添加敏感词")
    public ResponseResult insertSensitive(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insertSensitiveList(adSensitive);
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改敏感词")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.updateSensitiveList(adSensitive);
    }

    @PostMapping("/delete/{id}")
    @ApiOperation(value = "删除敏感词")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteSensitiveListById(id);
    }

    @PostMapping("/sensitives")
    @ApiOperation(value = "查询敏感词内容列表")
    public ResponseResult sensitives(){
        return adSensitiveService.selectAllSensitives();
    }
}
